import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig ({
    plugins: [
        vue (),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath (new URL ('./src', import.meta.url))
        }
    },
    server: {
        https: false,
        host: '0.0.0.0',
        proxy: {
            '/monitor': {
                target: 'http://127.0.0.1:9090/monitor/', // 接口的域名
                secure: false, // 如果是https接口，需要配置这个参数
                changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
                rewrite: path => path.replace (/^\/monitor/, '')
            },
            '/monitor/ws/': {
                target: 'ws://127.0.0.1:9090/monitor/ws/', // 接口的域名
                secure: false, // 如果是https接口，需要配置这个参数
                changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
                ws: true,
                rewrite: path => path.replace (/^\/monitor\/ws/, '')
            }
        },
    }
})
